package me.zhengjie.service.impl;

import lombok.RequiredArgsConstructor;
import me.zhengjie.pojo.dto.AgvRequestLiftDto;
import me.zhengjie.pojo.entity.LiftWaitPoint;
import me.zhengjie.pojo.vo.AgvTaskSubmitVo;
import me.zhengjie.service.LiftService;
import me.zhengjie.sqlservice.LiftWaitPointService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.LocalDateTime;

@Service
@RequiredArgsConstructor
public class LiftServiceImpl implements LiftService {
    private static final Logger haikang = LoggerFactory.getLogger("haiKang");

    private final LiftWaitPointService liftWaitPointService;

//    @Transactional
//    @Override
//    public AgvTaskSubmitVo agvRequestLift(AgvRequestLiftDto agvRequestLiftDto) {
//        haikang.info("请求电梯请求参数：{}",agvRequestLiftDto);
//        //设备编号
//        String eqptCode = agvRequestLiftDto.getEqptCode();
//        //设备名称
////        String eqptName = agvRequestLiftDto.getEqptName();
//        //任务号为唯一编号，可使用 UUID
//        String taskCode = agvRequestLiftDto.getTaskCode();
//        //任务执行方法，与设备相关，可扩展枚举值。
//        String method = agvRequestLiftDto.getMethod();
//        //起点
//        String srcCode = agvRequestLiftDto.getSrcCode();
//        //终点
//        String dstCode = agvRequestLiftDto.getDstCode();
//
//        LiftWaitPoint liftWaitPoint = new LiftWaitPoint();
//        liftWaitPoint.setLiftCode(eqptCode);
//        liftWaitPoint.setTaskCode(taskCode);
//        liftWaitPoint.setStartFloor(srcCode);
//        liftWaitPoint.setEndFloor(dstCode);
//        liftWaitPoint.setCreateTime(LocalDateTime.now());
//        //电梯任务创建
//        boolean b = liftWaitPointService.insertLiftWaitPoint(liftWaitPoint);
//        if (!b){
//            haikang.error("创建电梯等待点失败，数据库异常");
//            throw new RuntimeException("创建电梯等待点失败，数据库异常");
//        }
//        return AgvTaskSubmitVo.OK(null);
//    }
}
